<?php

use yii\grid\GridView;
use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '微信用户列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<style>
    .user-index img{width:80px;height:80px;margin-right:10px;}
</style>
<div class="user-index">
    <?= $this->render('_search', ['model' => $searchModel]) ?>
    <div class="box box-primary">
        <div class="box-body">
            <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'columns' => [
                    'uid',
                    'nick',
                    [
                        'attribute' => 'photo',
                        'format' => 'image',
                        'value'=>function($data) { return $data->photo; },
                            'options' => ['width' => '10%'],
                        ],
                    'coin',
                    [
                    'attribute' => 'gender',
                    'value' => function($model) {
                    return \common\helpers\Util::getSex($model->gender);
                    }
                    ],
                    'province',
                    'city',
                    'role',
                    [
                        'class' => 'yii\grid\ActionColumn',
                        'template' => '{view} {settest}',
                        'buttons' => [
                            'settest' => function($url, $model, $key) {
                                return Html::a("设为测试人员",
                                        ['/user-info/setrole', 'id' => $model->id],
                                        [
                                        'class' => 'btn btn-default btn-xs',
                                        'title' => '设为测试人员',
                                        'data-confirm' => '确定要设置用户吗?',
                                        'data-ajax' => '1',
                                        'data-method' => 'post'
                                        ]
                                        );
                            } 
                        ]
                    ],
                ],
            ]); ?>
        </div>
    </div>

</div>
<?php $this->beginBlock('js') ?>
<script>
    layer.ready(function () {
        layer.photos({
            photos:'.user-index',
            shift:5
        });
    })
</script>
<?php $this->endBlock() ?>
